<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="embroot.css">
<TITLE>
Constructing ECLiPSe terms in C
</TITLE>
</HEAD>
<BODY >
<A HREF="embroot073.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="embroot075.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H2 CLASS="section"><A NAME="htoc139">C.1</A>&nbsp;&nbsp;Constructing ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> terms in C</H2>
All these functions return (volatile) pwords, which can be used as input
to other constructor functions, or which can be stored in (non-volatile)
ec_refs.
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
<B>pword		ec_string(const char*)</B><DD CLASS="dd-description"><BR>
	converts a C string to an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> string. The string is copied.<BR>
<BR>
<DT CLASS="dt-description"><B>pword		ec_length_string(int, const char*)</B><DD CLASS="dd-description"><BR>
	converts a C string of given length to an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> string.
	The string is copied and can contain NUL bytes.<BR>
<BR>
<DT CLASS="dt-description"><B>pword		ec_atom(const dident)</B><DD CLASS="dd-description"><BR>
	creates an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> atom. A dident (dictionary identifier)
	can be obtained either via ec_did() or ec_get_atom().<BR>
<BR>
<DT CLASS="dt-description"><B>pword		ec_long(const long)</B><DD CLASS="dd-description"><BR>
	converts a C long to an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> integer.<BR>
<BR>
<DT CLASS="dt-description"><B>pword		ec_double(const double)</B><DD CLASS="dd-description"><BR>
	converts a C double to an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> float.<BR>
<BR>
<DT CLASS="dt-description"><B>pword		ec_term(dident,pword,pword,...)</B><DD CLASS="dd-description"><BR>
	creates an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> term from the given components.<BR>
<BR>
<DT CLASS="dt-description"><B>pword		ec_term_array(const dident,const pword[&nbsp;])</B><DD CLASS="dd-description"><BR>
	creates an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> term from the arguments given in the array.<BR>
<BR>
<DT CLASS="dt-description"><B>pword		ec_list(const pword,const pword)</B><DD CLASS="dd-description"><BR>
	creates a single ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> list cell with the given head (car) and tail (cdr).<BR>
<BR>
<DT CLASS="dt-description"><B>pword		ec_listofrefs(ec_refs)</B><DD CLASS="dd-description"><BR>
	creates an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> list containing the elements of the ec_refs array.<BR>
<BR>
<DT CLASS="dt-description"><B>pword		ec_listoflong(int, const long*)</B><DD CLASS="dd-description"><BR>
	creates an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> list of integers containing the longs in the given array.
	The data is copied.<BR>
<BR>
<DT CLASS="dt-description"><B>pword		ec_listofchar(int, const char*)</B><DD CLASS="dd-description"><BR>
	creates an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> list of integers containing the chars in the given array.
	The data is copied.<BR>
<BR>
<DT CLASS="dt-description"><B>pword		ec_listofdouble(int, const double*)</B><DD CLASS="dd-description"><BR>
	creates an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> list of doubles containing the doubles in the given array.
	The data is copied.<BR>
<BR>
<DT CLASS="dt-description"><B>pword		ec_arrayofdouble(int, const double*)</B><DD CLASS="dd-description"><BR>
	creates an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> array (a structure with functor [&nbsp;]of
	appropriate arity) of doubles from the given C array.
	The data is copied.<BR>
<BR>
<DT CLASS="dt-description"><B>pword		ec_matrixofdouble(int rows, int cols, const double*)</B><DD CLASS="dd-description"><BR>
	creates an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> array (size rows) of arrays (size cols) of doubles
	from the given C array. The data is copied.<BR>
<BR>
<DT CLASS="dt-description"><B>pword		ec_handle(const t_ext_type*,const t_ext_ptr)</B><DD CLASS="dd-description"><BR>
	creates an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> handle that refers to the given C data and its
	method table.<BR>
<BR>
<DT CLASS="dt-description"><B>pword		ec_newvar()</B><DD CLASS="dd-description"><BR>
	creates a fresh ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> variable.<BR>
<BR>
<DT CLASS="dt-description"><B>pword		ec_nil()</B><DD CLASS="dd-description"><BR>
	creates an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> nil ie. the empty list [&nbsp;].
</DL>
Auxiliary functions to access the ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> dictionary.
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description">
<B>dident		ec_did(char*,int)</B><DD CLASS="dd-description"><BR>
	looks up or enters the given string with arity into the ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP>
	dictionary and returns a unique identifier for it.
<DT CLASS="dt-description"><B>char*		DidName(dident)</B><DD CLASS="dd-description"><BR>
	returns the name string of the given dictionary identifier.
<DT CLASS="dt-description"><B>int		DidArity(dident)</B><DD CLASS="dd-description"><BR>
	returns the arity of the given dictionary identifier.
</DL>
<HR>
<A HREF="embroot073.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="embroot075.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
